import java.io.File;
import java.io.RandomAccessFile;

import kbps.io.BufferedRandomAccessFile;


public class TestRAF {

	public static void main(String[] args) {
		
		long t0 = System.currentTimeMillis();
		{
			RandomAccessFile raf = null;

			try {
				raf = new RandomAccessFile(new File("c:/test.txt"), "rw");

				byte[] buf = "Hello RandomAccessFile!\n".getBytes();
				for (int i = 0; i < 100; ++i) {
					raf.write(buf);
				}
			} catch (Exception e) {
			} finally {
				try {
					raf.close();
				} catch (Exception e) {
				}
			}
		}
		System.out.println("time0=" + (System.currentTimeMillis() - t0));
		
		t0 = System.currentTimeMillis();
		{
			BufferedRandomAccessFile braf = null;
			
			try {
				braf = new BufferedRandomAccessFile("c:test2.txt", "rw");
				byte[] buf = "Hello RandomAccessFile!\n".getBytes();
				for (int i = 0; i < 100; ++i) {
					braf.write(buf);
				}
			} catch (Exception e) {
			} finally {
				try {
					braf.close();
				} catch (Exception e) {
				}
			}
		}
		System.out.println("time1=" + (System.currentTimeMillis() - t0));
	}
}
